package org.cangkuguanli.luoyuhang.mapper;

import org.apache.ibatis.annotations.*;
import org.cangkuguanli.luoyuhang.bean.Cangku;
import org.cangkuguanli.luoyuhang.bean.Huowu;

import java.util.List;

@Mapper
public interface CargoMapper {

    //查询货物
    List<Huowu> CargoInquiry(Huowu cargo);

    @Select("select * from huowu order by create_time desc limit 0,5;")
    List<Huowu> Latest();

    //chaxun 数量最少的货物
    @Select("select * from huowu order by huowu_shuliang desc limit 0,5;")
    List<Huowu> SmallQuantities();
    //按时间查询所有货物
    @Select("select * from huowu order by create_time desc ;")
    List<Huowu> allLatest();
    // anshuliang排序查询所有
    @Select("select * from huowu  order by huowu_shuliang desc;")
    List<Huowu> AllSmallQuantities();

    @Select("select * from huowu where huowu_mingcheng like concat('%',#{name},'%');")
    List<Huowu> Name(String name);

    //新增仓库数据
   // @Insert("insert into huowu  (huowu_bianhao,huowu_mingcheng,huowu_shuliang,huowu_guige,huowu_rukushijiuan,huowu_chukushijian,huowu_weizhi,huowu_zhuangtai,create_time,update_time) values (null, #{huowu_mingcheng}, #{huowu_shuliang}, #{huowu_guige}, #{huowu_rukushijian}, #{huowu_chukushijian},#{huowu_cangku}, #{huowu_zhuangtai}, NOW(), NOW());")
    List<Huowu>  AddWarehouse(Huowu warehouse);


    //根据id修改货物信息
    @Update("update huowu set  huowu_shuliang = #{huowu_shuliang}, \n" +
            "    huowu_guige = #{huowu_guige}, \n" +
            "    huowu_chukushijian = #{huowu_chukushijian}, \n" +
            "    update_time = NOW() where huowu_bianhao =#{huowu_bianhao} ;")
    void UpdWarehouse(Cangku warehouse);

    // 批量删除和遍历删除
    void DelWarehouse(List<String> ids);

    //删除所有数据
    @Delete("delete from cangku  ;")
    void DelAllWarehouse();
}
